package recursion.nowcoder.easy;

import java.util.Scanner;

/**
 * @author Stark
 * @description 走方格的方案数
 * 题目链接：https://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b?
 * tpId=37&&tqId=21314&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 * @date 2022/4/27 20:46
 **/
public class WaysOfSquareLattice {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int row = in.nextInt();
            int col = in.nextInt();
            int[][] arr = new int[row + 1][col + 1];
//            int i = 0,j = 0;
//            System.out.println(countWays(i,j,row,col));
            System.out.println(countWays(row,col));
        }
    }
    //方法一
//    static int countWays(int i,int j,int row,int col){
//        if(i == row && j == col)
//            return 1;
//        int x1 = 0,x2 = 0;
//        if(i < row)
//            x1 = countWays(i + 1,j,row,col);
//        if(j < col)
//            x2 = countWays(i,j + 1,row,col);
//        return x1 + x2;
//    }

    //方法二
    static int countWays(int i,int j){
        if((i == 1 && j >= 1) || (i >= 1 && j == 1))
            return i + j;
        return countWays(i - 1,j) + countWays(i,j - 1);
    }
}
